package cn.yuanqiao.web.controller.archive.liyong;

import cn.yuanqiao.archive.liyong.domain.SeniorQuery;
import cn.yuanqiao.archive.liyong.service.SeniorQueryService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 高级检索列表
 *
 * @ProjectName: JZSDAS
 * @Package: cn.yuanqiao.archive.liyong.controller
 * @ClassName: SeniorQueryController
 * @Author: lenovo
 * @Description: hbWang
 * @Date: 2023/9/22 10:22
 * @Version: 1.0
 */
@RestController
@RequestMapping("/archive/senior/query")
public class SeniorQueryController extends BaseController {
    @Autowired
    SeniorQueryService seniorQueryService;

    /**
     * 高级检索接口
     *
     * @param
     * @return cn.yuanqiao.common.core.web.domain.AjaxResult
     * @author hbWang
     * @date 2023/6/28 9:09
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody() SeniorQuery seniorQuery) {
        List<Map<String, Object>> query = seniorQueryService.seniorQuery(seniorQuery);
        if (ObjectUtils.isEmpty(query)) {
            query = new ArrayList<>();
        }
        return getDataTable(query);
    }

    /**
     * 查询查询条件字段
     *
     * @param
     * @return cn.yuanqiao.common.core.web.domain.AjaxResult
     * @author hbWang
     * @date 2023/6/28 9:09
     */
    @PostMapping("/fileds")
    public AjaxResult fileds(@RequestParam(name = "groupId", required = false) String groupId, @RequestParam(name = "qzh", required = false) String qzh, @RequestParam(name = "menuId") String menuId) {
        List<Map<String, Object>> query = seniorQueryService.queryApp(groupId, menuId, qzh);
        return AjaxResult.success(query);
    }
}
